//package com.ruoyi.scheduleTask
//
//import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
//import com.ruoyi.back.domain.UserChannelFunction
//import com.ruoyi.back.domain.UserChannelFunctionTask
//import com.ruoyi.back.mapper.UserChannelFunctionTaskMapper
//import com.ruoyi.back.service.UserChannelFunctionService
//import org.slf4j.Logger
//import org.slf4j.LoggerFactory
//import org.springframework.beans.factory.annotation.Autowired
//import org.springframework.scheduling.annotation.EnableScheduling
//import org.springframework.scheduling.annotation.Scheduled
//import org.springframework.stereotype.Component
//import java.util.*
//
//
//@Component
//@EnableScheduling   // 1.开启定时任务
//class UserChannelFunctionScheduleTask {
//
//    private val log: Logger = LoggerFactory.getLogger(UserChannelFunctionScheduleTask::class.java)
//
//    @Autowired
//    private lateinit var userChannelFunctionTaskMapper: UserChannelFunctionTaskMapper
//
//    @Autowired
//    private lateinit var userChannelFunctionService: UserChannelFunctionService
//
//    @Scheduled(fixedRate = 3000)
//    fun scheduleTask() {
//        userChannelFunctionTaskMapper.selectList(
//            KtQueryWrapper(UserChannelFunctionTask::class.java)
//                .eq(UserChannelFunctionTask::executeTime, Date())
//        )
//            .takeIf { it.isNotEmpty() }
//            ?.run {
//                forEach {
//                    userChannelFunctionService.save(UserChannelFunction().apply {
//                        userId = it.userId
//                        channelId = it.channelId
//                        functionId = it.functionId
//                    })
//                    userChannelFunctionTaskMapper.deleteById(it.id)
//                }
//            }
//    }
//
//
//}